package Design_patterns.creator_mode.singleton.demo3;

/**
 * @description: 懒汉式
 **/

public class Singleton {

    //1.私有构造方法
    private Singleton() {
    }

    //2.声明Singleton类型的变量
    private static Singleton instance;  // null

    //

    //3.提供一个公共访问方式，让外界获取
    public static synchronized Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }
}
